﻿using System;
using System.Collections.Generic;
using System.Text;

public class ElectricEngine : Engine
{
    private float? m_BatteryHoursLeft = null;
    private float? m_MaxBatteryHours = null;

    public ElectricEngine(float i_MaxBatteryHours)
    {
        m_MaxBatteryHours = m_BatteryHoursLeft = i_MaxBatteryHours;
        this.EngineType = eEngineType.Electric;
    }

    public void LoadBattery(float i_BatteryHoursToLoad)
    {
        if (i_BatteryHoursToLoad + m_BatteryHoursLeft <= m_MaxBatteryHours)
        {
            m_BatteryHoursLeft = i_BatteryHoursToLoad;
        }
        else
        {
            throw new ValueOutOfRangeException("The amount is higher than the max hour to charge", 0, m_MaxBatteryHours.Value);
        }
    }

    public new virtual string ToString()
    {
        string str = base.ToString();
        str = string.Concat(str, "Current electric level: ", m_BatteryHoursLeft.ToString());

        return str;
    }
}